package com.tedu._04mybatis.mapper;

import com.tedu._04mybatis.pojo.Comment;
import com.tedu._04mybatis.pojo.CommentVO1;
import com.tedu._04mybatis.pojo.CommentVO2;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface CommentMapper {
    @Insert("insert into comment(content,created,user_id,weibo_id) " +
            "values(#{content},now(),#{userId},#{weiboId})")
    int insertComment(Comment comment);
    @Delete("delete from comment where id=#{id}")
    int deleteCommentById(Integer id);
    @Update("update Comment set content=#{content}," +
            "created=now(),user_id=#{userId},weibo_id=#{weiboId} " +
            "where id=#{id}")
    int updateCommentById(Comment comment);
    @Select("select content,user_id userId from comment " +
            "where id=#{id}")
    CommentVO1 selectCommentById(Integer id);
    @Select("select user_id userId,content,id from comment " +
            "where user_id=#{id}")
    List<CommentVO2> selectCommentByUserId(Integer id);
    int deleteCommentByIds(Integer[] ids);

}
